<?php
include('../../include/init.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>钢筋平法考试模拟系统登陆</title>
<base href="<?php echo(DOMAIN_ROOT);?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- IE8 mode :IE=500-->
<link href="resources/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="passport/register/check_reg.js"></script>
</head>

<body>
<?php
$action = fs_get_value('do');
switch($action){
case 'do_registe'      :       do_registe()     ; break;
default                :       main()           ; break;
}
?>
<?php
function main(){
?>
<div class="registe_main">
	<div class="registe">
	  <form action="<?php echo(DIR_ROOT_A);?>/passport/register/?do=do_registe" method="post" name="reg" onsubmit="return check_reg();" >
		<div class="registe_content">
			<div class="registe_content_top">
				<div class="registe_content_top_left"><img src="resources/images/biaozhi.gif" border="0"  /></div>
				<div class="registe_content_top_right"><img src="resources/images/biaoti.gif" border="0"  /></div>
			</div>
			<div class="registe_content_middle_top">* 用户注册   带*的必填</div>
			<div class="registe_content_middle_form1">
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">登陆账号： </div>
					<div class="registe_content_middle_form1_list_center"><input type="text" name="username" class="login_content_input" onblur="check_userinfo(this.value)" /></div>
					<div id="user_info" class="registe_content_middle_form1_list_right">* </div>
				</div>
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">登陆密码： </div>
					<div class="registe_content_middle_form1_list_center"><input type="password" name="password" class="login_content_input" onblur="check_pass(this.value);" /></div>
					<div id="user_pass" class="registe_content_middle_form1_list_right">* </div>
				</div>
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">确认密码： </div>
					<div class="registe_content_middle_form1_list_center"><input type="password" name="password2" class="login_content_input" onkeyup="check_true_pass(this.value);" /></div>
					<div id="user_truepass" class="registe_content_middle_form1_list_right">* </div>
				</div>
			</div>
			<div class="registe_content_middle_middle">完善资料(选填)</div>
			<div class="registe_content_middle_form2">
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">真实姓名： </div>
					<div class="registe_content_middle_form1_list_center"><input type="text" name="realname" class="login_content_input" /></div>
					<div class="registe_content_middle_form1_list_right"></div>
				</div>
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">联系电话： </div>
					<div class="registe_content_middle_form1_list_center"><input type="text" name="tel" class="login_content_input" /></div>
					<div class="registe_content_middle_form1_list_right"></div>
				</div>
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">电子邮箱： </div>
					<div class="registe_content_middle_form1_list_center"><input type="text" name="email" class="login_content_input" /></div>
					<div class="registe_content_middle_form1_list_right"></div>
				</div>
				<div class="registe_content_middle_form1_list">
					<div class="registe_content_middle_form1_list_left">QQ号码： </div>
					<div class="registe_content_middle_form1_list_center"><input type="text" name="qq" class="login_content_input" /></div>
					<div class="registe_content_middle_form1_list_right"></div>
				</div>
			</div>
			<div class="registe_content_middle_bottom">
				<div class="registe_content_middle_bottom_left"><input type="image" src="resources/images/registe2.png" /></div>
				<div class="registe_content_middle_bottom_right"><a href="passport/login/"><img src="resources/images/login2.png" border="0" /></a></div>
			</div>
			<div class="registe_content_bottom">山东济南奥体科发展有限公司</div>
		</div>
	  </form>
	</div>
</div>
<?php
}
function do_registe(){
	global $db;
	$username = fs_get_value('username');
	$password = fs_sha1(fs_get_value('password'));
	$password2 = fs_sha1(fs_get_value('password2'));
	$realname = fs_get_value('realname');
	$tel = fs_get_value('tel');
	$email = fs_get_value('email');
	$qq = fs_get_value('qq');
	if($username == ''){
		fs_showmsg("登陆账户不能为空！");
		exit();
	}
	$num = $db -> row_count(TABLE_MEMBER,"passport = '".$username."' and state = 1");
	if($num > 0){
		fs_showmsg("该用户名已存在！");
		exit();
	}
	if(fs_get_value('password') == '' || fs_get_value('password2') == ''){
		fs_showmsg("密码不能为空！");
		exit();
	}
	else{
		if($password != $password2){
			fs_showmsg("两次密码输入不一致！");
			exit();
		}
	}
	if($username != '' && $password != ''){
		$sql = "insert into ".TABLE_MEMBER." (`passport`,`password`) value ('".$username."','".$password."')";
		$db -> query($sql);
		$id = mysql_insert_id();
	}
	if($realname != ''){
		$sql = "update ".TABLE_MEMBER." set realname = '".$realname."' where id = ".$id;
		$db -> query($sql);
	}
	if($tel != ''){
		$sql = "update ".TABLE_MEMBER." set tel = '".$tel."' where id = ".$id;
		$db -> query($sql);
	}
	if($email != ''){
		$sql = "update ".TABLE_MEMBER." set email = '".$email."' where id = ".$id;
		$db -> query($sql);
	}
	if($qq != ''){
		$sql = "update ".TABLE_MEMBER." set qq = '".$qq."' where id = ".$id;
		$db -> query($sql);
	}
	if($id != ''){
		$sql = "update ".TABLE_MEMBER." set state = 1,logintimes = 0,registerdate = '".date("Y-m-d H:i:s",time())."' where id = ".$id;
		$db -> query($sql);
	}
	fs_showmsg("注册成功！",DIR_ROOT_A."/passport/login/");
	exit();
}
?>
</body>
</html>